package com.lgkj.ui.userinfo;

import android.widget.ImageView;
import android.widget.TextView;

import com.lgkj.R;
import com.lgkj.ui.BaseActivity;
import com.lgkj.utils.CommonConstant;
import com.lgkj.utils.CommonUtils;
import com.lgkj.utils.HttpUtils;

import org.json.JSONObject;

import java.util.HashMap;
import java.util.Map;

import butterknife.BindView;

/**
 * Created by Administrator on 2018/8/20 0020.
 */

public class ExtendActivity extends BaseActivity {
    @BindView(R.id.tv_titles)
    TextView tvTitle;
    @BindView(R.id.iv_img)
    ImageView ivImg;

    @Override
    public int getLayoutId() {
        return R.layout.activity_extend;
    }

    @Override
    public void initView() {
        setTitle("我的推广码");
    }

    @Override
    public void initData() {
        Map<String, String> map = new HashMap<>();
        map.put("access_token", CommonUtils.getToken(ExtendActivity.this));
        HttpUtils.postHttp(map, CommonConstant.getUserQr, new HttpUtils.HttpCallBack() {
            @Override
            public void successHttp(JSONObject jsonObject, int id) {
                if (jsonObject.optInt("code") == 0) {
                    tvTitle.setText("我的推广码:" + jsonObject.optJSONObject("data").optString("active_code"));
                    String url = jsonObject.optJSONObject("data").optString("file_path");
                    CommonUtils.LoadImage(ExtendActivity.this, ivImg, url, R.mipmap.tuiguagnma);
                } else {
                    toastLong(jsonObject.optString("msg"), 0);
                }
            }

            @Override
            public void errorHttp(String msg) {
            }
        });
    }

}
